package org.skipper.ai.impl;

import org.skipper.ai.AiClient;
import org.skipper.ai.enums.AiTypeEnum;
import org.skipper.ai.param.SimpleChatParam;
import org.skipper.ai.result.SimpleChatResult;
import org.skipper.ai.strategy.ChatContext;
import org.skipper.ai.strategy.ChatStrategy;
import org.skipper.ai.strategy.result.ChatResult;

/**
 * Created with IntelliJ IDEA.
 * Description: TODO
 *
 * @author shoujian
 * Date: 2025-10-09
 * Time: 15:49
 */
public class AiClientImpl implements AiClient {
    @Override
    public SimpleChatResult chat(SimpleChatParam simpleChatParam) {

        ChatContext chatContext = new ChatContext();

        ChatStrategy chatStrategy = chatContext.getInstance(AiTypeEnum.getByCode(simpleChatParam.getAiType()));

        ChatResult chatResult = chatStrategy.chat(chatContext.buildChatParam(simpleChatParam));
        SimpleChatResult simpleChatResult = new SimpleChatResult();
        simpleChatResult.setResult(chatResult.getText());

        return simpleChatResult;
    }
}
